
from kivy.uix.floatlayout import FloatLayout

from amgineirc.view.channels.logView import LogView
from amgineirc.view.channels.sendView import SendView
from amgineirc.view.channels.listView import ListView
from amgineirc.viewModel.channels.serverViewModel import ServerViewModel

"""
content for a notebook view
left-top = log view
right-top = users view
bottom = send view
"""
class ServerView(FloatLayout):
    def __init__(self, appdata):
        
        FloatLayout.__init__(self, size_hint=(1.0, 1.0))
        # the recieve view - top left
        self.receive_view = LogView(size_hint=(0.75, 0.9),
                                    pos_hint={'x':0.0, 'y':0.1})
        self.add_widget(self.receive_view)
        # the channels view - top right
        self.channels_view = ListView(size_hint=(0.25, 0.9),
                                      pos_hint={'x':0.75, 'y':0.1})
        self.add_widget(self.channels_view)
        # the send view - bottom
        self.send_view = SendView(size_hint=(1.0, 0.1),
                                  pos_hint={'x':0.0, 'y':0.0})
        self.add_widget(self.send_view)
        # initialize the view model
        self.view_model = ServerViewModel(self,
                                          self.send_view,
                                          self.receive_view,
                                          self.channels_view,
                                          appdata)
                                          
    def parent_handler(self, *largs):
        s = repr(largs)
        ##Logger.debug('ServerView: parent_handler largs = ' + s)
        if self.parent is None:
            self.view_model.handle_on_remove()

    # view model methods for wrapper view not this view

    def vm_set_state(self, **kargs):
        # if 'connected' in kargs:
        # show connected
        pass
